package de.ventu.picpic.object
{
    import flash.display.MovieClip;
	import flash.display.Loader;
	import flash.net.URLRequest;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.PixelSnapping;  
    import flash.events.*;
    
    import uk.soulwire.utils.display.DisplayUtils;
    import uk.soulwire.utils.display.Alignment;
	
	public class ImageObject extends MovieClip
	{   
		public function ImageObject(url:String)
		{
		    var loader:Loader = new Loader();			
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
			loader.load(new URLRequest(url));
		}
		
		private function completeHandler(event:Event):void
		{
		    var bitmap:Bitmap = Bitmap(Loader(event.target.loader).content);
		    
			trace(bitmap.height.toString());
			trace(bitmap.width.toString());            
            
            height = bitmap.height;
            width = bitmap.width;
            
            var thumb:Bitmap = DisplayUtils.createThumb(bitmap.bitmapData, 100, 100, 
                Alignment.MIDDLE, true);
			
			bitmap = null;
			
			this.addChild(thumb);
	    }
	}
}